<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
html{background-color:#E3E3E3; font-size:14px; color:#000; font-family:'微软雅黑'}
a,a:hover{ text-decoration:none;}
pre{font-family:'微软雅黑'}
.box{padding:20px; background-color:#fff; margin:50px 100px; border-radius:5px;}
.box a{padding-right:15px;}
#about_hide{display:none}
.layer_text{background-color:#fff; padding:20px;}
.layer_text p{margin-bottom: 10px; text-indent: 2em; line-height: 23px;}
.button{display:inline-block; *display:inline; *zoom:1; line-height:30px; padding:0 20px; background-color:#56B4DC; color:#fff; font-size:14px; border-radius:3px; cursor:pointer; font-weight:normal;}
.photos-demo img{width:200px;}
</style>
</head>
<body>
<div class="box">

<?php
$url='http://uc.cc/sso.php';
$service='http://i.uc.cc/server/index.php';
$service_ajax='http://i.uc.cc/server/index.php/welcome/ajax_check?jsoncallback=?';
$log_url=$service.'?url='.$url;
//@$username=$_GET["info"];
@$username=$_COOKIE['username'];
if(empty($username)){
	echo '<a href="javascript:void(0)" id="login">请登录</a>';
	//echo '<a href="'.$log_url.'">请登录</a>';
}else{
	//echo '欢迎'.$username.'登录 || <a href="http://i.uc.cc/server/index.php/welcome/logout?url='.$url.'">退出</a>';
	echo '欢迎'.$username.'登录 || <a href="javascript:void(0)" id="logout">退出</a>';
}
?>

<script src="jquery.js"></script>
<script src="layer/layer.js"></script>

<script type="text/javascript">
$(function(){
	//登录
	$('#login').click(function(){
		$.getJSON("<?=$service_ajax?>", function(json){
            if(json.msg==2){
            	document.cookie="username="+json.username;
                window.location.reload(); 
            }else{
                //window.location.href="<?=$log_url?>"
                login_ajax()
            }
             
        });
	})

	//登录窗口
	function login(){

    layer.open({
      type: 2,
      title: '登录窗口',
      shadeClose: true,
      shade: false,
      //maxmin: true, //开启最大化最小化按钮
      area: ['100px', '95px'],
      content: 'http://i.uc.cc/server/index.php'
    });
	}

	function login_ajax(){
		$.get(
			"./sso_login.php",
                function(data){
                    layer.open({
                        title:'添加项目',
                        type: 1,
                        skin: 'layui-layer-demo', //样式类名
                        shift: 5,
                        area:'400px',
                        content: data,
                        btn: ['确定','取消'],
                        yes: function(index, layero){ //或者使用btn1

                            data = {
                                pwd:$("#pwd").val(),
                                username:$("#username").val(),
                            };

                            $.getJSON("http://i.uc.cc/server/index.php/welcome/login?jsoncallback=?",data, function(json){
                                   if(json.msg==2){
                                   	document.cookie="username="+json.username;
                                    window.location.reload(); 
                                   }else{
                                   	layer.msg('用户名或密码错误');
                                   }
             
                            });
                        },cancel: function(index){ //或者使用btn2
                            //按钮【按钮二】的回调
                        }
                    });
                },
                "text"
            );
	}

	//退出登录
	$('#logout').click(function(){
		$.getJSON("http://i.uc.cc/server/index.php/welcome/ajax_ogout?jsoncallback=?", function(json){
			if(json.msg==1){
              document.cookie="username="+json.username;
              window.location.reload(); 
			}
            
        });
	})


})
  

</script>
</body>
</html>
	

